<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.zust.java.bean.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>加工者页面</title>
</head>
<%      
    List<Order> list = (List<Order>) request.getSession().getAttribute("order");
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
%>
<% 
    Account account = (Account) request.getSession().getAttribute("account");
    JobShop jobShop = (JobShop) request.getSession().getAttribute("jobShop");
%>
<body>
	
	<form action="searchOrder" method="post">
	   <input name="username" type="text">
	   <input name="submit" type="submit" value="查询">
	</form>
	<br> <button name="drop" onclick="window.location.href='dropServlet'">退出</button>
	<br> <button name="findAll" onclick="window.location.href='selectProcessorOrder?jobShopId=<%= jobShop.getId()%>'">查看我的订单</button>
	<table border="1px" style="text-align:center">
	<tr>   
        <th>订单号</th>
        <th>创建时间</th>
        <th>最终期限</th>
        <th>下单者</th>
        <th>接单人</th>
        <th>操作</th>
    </tr>
    <%
        for (Order o : list) {
    %>
    <tr>
        <td><%= o.getOrderNo()  %></td>
        <td><%= dateFormat.format(o.getCreatTime()) %></td>
        <td><%= dateFormat.format(o.getDeadline()) %></td>
        <td><%= o.getAccount().getUsername() %></td>
        <%
            if (o.getJobShop() != null && o.getJobShop().getId() != 0){
        %>
        、          <td><%= o.getJobShop().getJobNo() %></td>
        <% } else { %>
            <td>null</td>
        <% } %>
        <td>
            <button name="select" onclick="window.location.href='selectOrderDetail?orderNo=<%= o.getOrderNo() %>&account1=<%= account.getAccount() %>&type=<%=account.getType()%>'">查看详情</button>
            <button name="catch" onclick="window.location.href='orderAddJobShop?jobShopId=<%= jobShop.getId() %>&orderNo=<%= o.getOrderNo() %>'">接单</button>
        </td>
    </tr>
	<% } %>
	</table>
</body>
</html>